f = open('p042_words.txt', 'r')
w = []
for line in f:
    line = line.split(',')
    for ww in line:
        w.append(ww[1:-1])

ans = 0
t = [x * (x + 1) / 2 for x in xrange(1, 100)]
d = {}
for x in t:
    d[x] = 1

for word in w:
    count = 0
    for s in word:
        count += ord(s) - ord('A') + 1
    if count in d:
        ans += 1

print ans
